@extends('admin.master')

@section('top')
<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render('user-edit') !!}</div>
@endsection

@section('content')
<div class="container-body">
{!! Form::model($user, ['route' => ['admin.user.update', $user->id], 'method'=>'patch', 'class'=>'form-horizontal']) !!}
	<div class="form-group">
		<label class="col-sm-4 control-label label-width"><span class="text-danger">*</span> 用户名：</label>
		<div class="col-sm-8 row">
			{!! Form::text('username', null, ['class'=>'form-control len', 'data-rule'=>'required']) !!}
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width"><span class="text-danger">*</span> 姓名：</label>
		<div class="col-sm-8 row">
			{!! Form::text('name', null, ['class'=>'form-control len', 'data-rule'=>'required']) !!}
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width">手机号码：</label>
		<div class="col-sm-8 row">
			{!! Form::text('phone', null, ['class'=>'form-control len']) !!}
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width">邮箱：</label>
		<div class="col-sm-8 row">
			{!! Form::text('email', null, ['class'=>'form-control len']) !!}
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width">QQ：</label>
		<div class="col-sm-8 row">
			{!! Form::text('qq', null, ['class'=>'form-control len']) !!}
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width">职位：</label>
		<div class="col-sm-8 row">
			{!! Form::text('job', null, ['class'=>'form-control len']) !!}
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width">所属部门：</label>
		<div class="col-sm-8 row">
			<div class="department-select" id="department">
				<select name="region_id" class="form-control len150 region"></select>
				<select name="department_id" class="form-control len150 department"></select>
			</div>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width"><span class="text-danger">*</span> 用户组：</label>
		<div class="col-sm-8 row">
			{!! Form::select('gid', $group, null, ['class'=>'form-control len', 'v-model'=>'gid']) !!}
		</div>
	</div>
	<div class="form-group" v-if="gid==3">
		<label class="col-sm-4 control-label label-width text-success"><strong>设计师 TEAM：</strong></label>
		<div class="col-sm-8 row">
			{!! Form::select('team', ['请选择分组'] + config('system.team'), null, ['class'=>'form-control len', 'v-model'=>'team']) !!}
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width text-danger">操作：</label>
		<div class="col-sm-8 row">
			<div class="checkbox">
			    <label class="text-danger">
			    	{!! Form::checkbox('status', 0, !$user->status) !!} 冻结该用户
			    </label>
			</div>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-4 control-label label-width"></label>
		<div class="col-sm-8 row">
			{!! Form::submit('提交', ['class'=>'btn btn-primary']) !!}
		</div>
	</div>
{!! Form::close() !!}
</div>
@endsection

@section('foot')
<script src="{{ url('js/department.js') }}"></script>
<script src="{{ url('js/nice-validator/jquery.validator.js?local=zh-CN') }}"></script>
<script src="{{ url('js/department.js') }}"></script>
<script type="text/javascript">
	var departments = {!! json_encode($departmentsTree, JSON_UNESCAPED_UNICODE) !!};

	department.init({
		regions: departments,
		departments: departments,
		where: {!! $user !!},
	}).make();

	var vm = new Vue({
		el: '#content',
		data: {
			'gid': 0,
			'team': {{ $user->team }}
		}
	})

</script>	
@endsection